import request from '@/utils/request'

// 查询合同列表
export function listContract(query) {
  return request({
    url: '/system/contract/list',
    method: 'get',
    params: query
  })
}

// 查询合同详细
export function getContract(contractId) {
  return request({
    url: '/system/contract/' + contractId,
    method: 'get'
  })
}

// 新增合同
export function addContract(data) {
  return request({
    url: '/system/contract',
    method: 'post',
    data: data
  })
}

// 修改合同
export function updateContract(data) {
  return request({
    url: '/system/contract',
    method: 'put',
    data: data
  })
}

// 删除合同
export function delContract(contractId) {
  return request({
    url: '/system/contract/' + contractId,
    method: 'delete'
  })
}

// 导出合同
export function exportContract(query) {
  return request({
    url: '/system/contract/export',
    method: 'get',
    params: query
  })
}

// 下载合同
export function downloadContract(contractId) {
  return request({
    url: '/system/contract/download/' + contractId,
    method: 'get',
    responseType: 'blob'
  })
}

// 预览合同
export function previewContract(contractId) {
  return request({
    url: '/system/contract/preview/' + contractId,
    method: 'get'
  })
}

// 审核合同
export function approveContract(data) {
  return request({
    url: '/system/contract/approve',
    method: 'post',
    data: data
  })
}

// 驳回合同
export function rejectContract(data) {
  return request({
    url: '/system/contract/reject',
    method: 'post',
    data: data
  })
}

// 获取合同统计信息
export function getContractStats(userId) {
  return request({
    url: '/system/contract/stats',
    method: 'get',
    params: { userId }
  })
}

// 获取合同类型统计
export function getContractTypeStats(userId) {
  return request({
    url: '/system/contract/typeStats',
    method: 'get',
    params: { userId }
  })
}
